module cl {
	export class FlashTileEffect {
		public constructor(private map : CampaignPage, public tids : number[]) {
			this.tiles = [];
			for (let tid of tids) {
				let tile = Util.setImageTid("tile_real_png", tid);
				Util.setColor(tile, 1.0, 1.0, 1.0, 0.3);
				this.tiles.push(tile);
			}
		}

		private handle : number;
		private tiles : egret.DisplayObject[];
		private count : number;

		public play() : void {
			this.count = -1;
			this.handle = setInterval(()=>{
				this.count++;
				if (this.count % 3 == 0) {
					for (let tile of this.tiles) {
						this.map.groupEffect.addChild(tile);
					}
				} else if (this.count % 3 == 2) {
					for (let tile of this.tiles) {
						this.map.groupEffect.removeChild(tile);
					}
				}
			}, 250);
		}

		public stop() : void {
			clearInterval(this.handle);

			if (this.count % 3 != 2) {
				for (let tile of this.tiles) {
					this.map.groupEffect.removeChild(tile);
				}
			}
		}
	}
}